package com.jdew.thkj.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.net.Uri;
import android.os.Handler;
import android.support.v4.view.PagerAdapter;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.bumptech.glide.Glide;
import com.jdew.thkj.utils.Base64;
import com.jdew.thkj.utils.RegexValidateUtils;
import com.jdew.thkj.utils.ZXingUtils;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

/**
 * Created by yangzai on 2018/1/24 0024.
 */

public class MyViewpagerAdapter extends PagerAdapter {

    private List<String> list;
    private Context context;

    public MyViewpagerAdapter(List<String> list, Context context) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return Integer.MAX_VALUE;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        ImageView vp_iv = new ImageView(context);
        if (list.size() != 0) {
            Glide.with(context).load(list.get(position % list.size())).into(vp_iv);
            container.addView(vp_iv);
        }
        return vp_iv;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }
}
